package com.enums.enummap;

import com.enums.menu.AlarmPoints;

import java.util.EnumMap;
import java.util.Map;

import static com.enums.menu.AlarmPoints.*;

/**
 * @author ANG.YU
 * @date 2020-08-06 14:25
 */
interface Command {
    void action();
}

public class EnumMaps {
    public static void main(String[] args) {
        EnumMap<AlarmPoints, Command> em = new EnumMap<AlarmPoints, Command>(AlarmPoints.class);
        em.put(KITCHEN, () -> System.out.println("kitchen fire"));
        em.put(BATHROOM, () -> System.out.println("bathroom alert"));
        for (Map.Entry<AlarmPoints, Command> e : em.entrySet()) {
            System.out.print(e.getKey()+" ");//BATHROOM
            e.getValue().action();//bathroom alert
            //BATHROOM bathroom alert
        }
        try {
            em.get(UTILITY).action();
        } catch (Exception e) {
            System.out.println("Exception " + e);
        }
    }
}
